﻿@using RazorDemo2.Models
@model RazorDemo2.Models.Product

@{
    //Layout = "~/Views/_layout.cshtml";
    ViewBag.Title = "Index";
}
<label>hello</label>
产品名称是 @Model.Name
库存水平
@switch ((int)ViewBag.ProductCount)
{
    case 0:
        @:没货了
        break;
    case 1:
        <b>缺货</b>
        break;
    default:
        @ViewBag.ProductCount
        break;
}


@ViewData["greeting"]
<div data-discount="@ViewBag.ApplyDiscount"
     data-express="@ViewBag.ExpressShip"
      data-supplier="@ViewBag.Supplier">该标签含有数据属性</div>
打折：<input type="checkbox" checked="@ViewBag.ApplyDiscount"/>
快递: <input type="checkbox" checked="@ViewBag.ExpressShip" />    
供货商：<input type="checkbox"  checked="@ViewBag.Supplier"/> 


<hr />
@if (ViewBag.Products.Count > 0)
{
    <table>
        <thead>
        <tr>
            <th>名称</th>
            <th>价格</th>
        </tr>
        </thead>
        <tbody>
        @foreach (Product product in ViewBag.Products)
        {
            <tr>
                <td>@product.Name</td>
                <td>@product.Price</td>
            </tr>
        }
        </tbody>
    </table>
}
else
{
    <h2>没有产品信息</h2>
}